/*
* @Author: chenggh
* @Date: 2025-06-21
* @Link to Problem : https://webvpn.neu.edu.cn/https/62304135386136393339346365373340bfebea318fd008d8f60d257088/courses/27/part/223/problem/1007
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n, m, k; cin >> n >> m >> k;
	vector<int> a(n), b(m);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < m ; i++){
		cin >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	int p1 = 0, p2 = 0, ans = 0;
	while((p1 < n) && (p2 < m)){
		int l = b[p2] - k; // P2房子能满足的范围
		int r = b[p2] + k;
		if(a[p1] < l) p1++; // 房子太大
		else if(a[p1] > r) p2++;
		else {
			ans++;
			p1++;
			p2++;
		}
	}
	cout << ans << endl;
	return 0;
}